home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 May: Tool Chest / Developer CD Series May 1996 (Tool Chest) (Apple Computer) (1996).iso / Tool Chest / Development Tools & Languages / Dylan Related / Mindy / Mindy 1.2 - portable sources / interp / str.h < prev    next >
Encoding:
C/C++ Source or Header  |  1995-03-15  |  2.1 KB  |  61 lines  |  [TEXT/ttxt]

  1. /**********************************************************************\
  2. *
  3. *  Copyright (c) 1994  Carnegie Mellon University
  4. *  All rights reserved.
  5. *  
  6. *  Use and copying of this software and preparation of derivative
  7. *  works based on this software are permitted, including commercial
  8. *  use, provided that the following conditions are observed:
  9. *  
  10. *  1. This copyright notice must be retained in full on any copies
  11. *     and on appropriate parts of any derivative works.
  12. *  2. Documentation (paper or online) accompanying any system that
  13. *     incorporates this software, or any part of it, must acknowledge
  14. *     the contribution of the Gwydion Project at Carnegie Mellon
  15. *     University.
  16. *  
  17. *  This software is made available "as is".  Neither the authors nor
  18. *  Carnegie Mellon University make any warranty about the software,
  19. *  its performance, or its conformity to any specification.
  20. *  
  21. *  Bug reports, questions, comments, and suggestions should be sent by
  22. *  E-mail to the Internet address "gwydion-bugs@cs.cmu.edu".
  23. *
  24. ***********************************************************************
  25. *
  26. * $Header: str.h,v 1.4 94/10/05 21:04:30 nkramer Exp $
  27. *
  28. \**********************************************************************/
  29.  
  30.  
  31. extern obj_t obj_ByteStringClass;
  32. extern obj_t obj_UnicodeStringClass;
  33.  
  34. /* The following is the definition for both byte strings and unicode
  35.    strings.  Unicode strings are stored as two byte-characters in a
  36.    row, high byte first.  Unicode strings are terminated with the
  37.    unicode character 0x0000 (two null byte characters).  len refers
  38.    to the number of characters, not the number of bytes.
  39. */
  40. struct string {
  41.     obj_t class;
  42.     int len;
  43.     unsigned char chars[4];
  44. };
  45.  
  46. /* How you interpret the chars depends on whether its a byte string or 
  47.    a unicode string.
  48. */
  49. #define string_chars(str) (obj_ptr(struct string *, str)->chars)
  50.  
  51. /*
  52.    A convenient way to access unicode characters in a stream of 
  53.    unicode characters.  Returns an integer.
  54. */
  55. #define get_unichar(str,index) ((string_chars(str)[2*index] << 8) \
  56.                 + (string_chars(str)[2*index + 1]))
  57.  
  58.  
  59. extern obj_t make_byte_string(char *chars);
  60. extern obj_t alloc_byte_string(int len);
  61.